#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double calc_add(double param1, double param2, double *result)
{
    *result = param1 + param2;
    return *result;
}

double calc_sub(double param1, double param2, double *result)
{
    *result = param1 - param2;
    return *result;
}

double calc_mul(double param1, double param2, double *result)
{
    *result = param1 * param2;
    return *result;
}

double calc_div(double param1, double param2, double *result)
{
    *result = param1 / param2;
    return *result;
}

double calculate(double param1,
                 double param2,
                 double *result,
                 double (*calc)(double param1, double param2, double *result))
{
    return calc(param1, param2, result);
}

int main(int argc, char const *argv[])
{
    double ret1;
    double ret2;
    double ret3;
    double ret4;
    calculate(5, 8, &ret1, calc_add);
    calculate(5, 8, &ret2, calc_sub);
    calculate(5, 8, &ret3, calc_mul);
    calculate(5, 8, &ret4, calc_div);
    printf("ret1=%lf,ret2=%lf,ret3=%lf,ret4=%lf\n", ret1, ret2, ret3, ret4);
    return 0;
}
